package cn.ccbfund.demo.config;

import java.nio.charset.Charset;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@MapperScan(basePackages = { "cn.ccbfund.demo.mapper"})
public class MvcConfig extends WebMvcConfigurerAdapter {
    
    /**
     * 解决String转换中文乱码问题
     * @return
     */
    @Bean
    public StringHttpMessageConverter springHttpMessageConverter() {
    	StringHttpMessageConverter converter= new StringHttpMessageConverter();
    	converter.setDefaultCharset(Charset.forName("UTF-8"));
    	return converter;
    }
    
	@Bean
	public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) { 
		return restTemplateBuilder.setConnectTimeout(60000) 
				.setReadTimeout(60000).build();
	}

}
